<?php
namespace App\Http\Controllers\staff;

use DB;
use App\Http\Controllers\common\PublicController;
use Illuminate\Http\Request;

class LayoutController extends PublicController
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function getIndex(Request $request)
    {
        $data = $request -> cookie('staffInfo');
        return view('staff.layout.index',['data'=>$data]);
    }

    //请求侧边栏
    public function postGadget(){
        $info = '[
        {
                "id": 1, 
                "title": "统计概览", 
                "icon": "", 
                "href": "/staff/overview/index", 
                "spread": 0, 
                "module": "0101", 
                "children": []
            }, 
            {
                "id": 3, 
                "title": "服务维修", 
                "icon": "", 
                "href": "/staff/service/index", 
                "spread": 0, 
                "module": "0102", 
                "children": []
            },
            {
                "id": 4, 
                "title": "商铺信息", 
                "icon": "", 
                "href": "/staff/store/index", 
                "spread": 0, 
                "module": "0102", 
                "children": []
            },
            {
                "id": 5, 
                "title": "员工信息", 
                "icon": "", 
                "href": "/staff/account/index", 
                "spread": 0, 
                "module": "0102", 
                "children": []
            },
            {
                "id": 6, 
                "title": "仓储信息", 
                "icon": "", 
                "href": "/staff/storage/index", 
                "spread": 0, 
                "module": "0102", 
                "children": []
            }
        ]';
        echo $info;
    }

    //鼠标移入更换头像接口
    public function change(Request $request){
        $agent_id = $request -> cookie('logon')['agent_id'];
        //查询image库
        $res = DB::table('image') -> select('name','agent_id') -> where(['agent_id'=>$agent_id,'status'=>1]) -> first();
        return json_encode($res);
    }
}
